package com.ruoyi.finance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.finance.domain.EPayment;
import com.ruoyi.finance.service.IEPaymentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 支付记录Controller
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/payment")
public class EPaymentController extends BaseController
{
    @Autowired
    private IEPaymentService ePaymentService;

    /**
     * 查询支付记录列表
     */
    @RequiresPermissions("finance:payment:list")
    @GetMapping("/list")
    public TableDataInfo list(EPayment ePayment)
    {
        startPage();
        List<EPayment> list = ePaymentService.selectEPaymentList(ePayment);
        return getDataTable(list);
    }

    /**
     * 导出支付记录列表
     */
    @RequiresPermissions("finance:payment:export")
    @Log(title = "支付记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EPayment ePayment)
    {
        List<EPayment> list = ePaymentService.selectEPaymentList(ePayment);
        ExcelUtil<EPayment> util = new ExcelUtil<EPayment>(EPayment.class);
        util.exportExcel(response, list, "支付记录数据");
    }

    /**
     * 获取支付记录详细信息
     */
    @RequiresPermissions("finance:payment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(ePaymentService.selectEPaymentById(id));
    }

    /**
     * 新增支付记录
     */
    @RequiresPermissions("finance:payment:add")
    @Log(title = "支付记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EPayment ePayment)
    {
        return toAjax(ePaymentService.insertEPayment(ePayment));
    }

    /**
     * 修改支付记录
     */
    @RequiresPermissions("finance:payment:edit")
    @Log(title = "支付记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EPayment ePayment)
    {
        return toAjax(ePaymentService.updateEPayment(ePayment));
    }

    /**
     * 删除支付记录
     */
    @RequiresPermissions("finance:payment:remove")
    @Log(title = "支付记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(ePaymentService.deleteEPaymentByIds(ids));
    }
}
